<template>
  <div class="settings-container">
    <el-card>
      <template #header>
        <div class="card-header">
          <span>系统设置</span>
        </div>
      </template>

      <el-form :model="formData" label-width="120px">
        <el-form-item label="系统名称">
          <el-input v-model="formData.systemName" />
        </el-form-item>

        <el-form-item label="API地址">
          <el-input v-model="formData.apiUrl" />
        </el-form-item>

        <el-form-item label="消息保存天数">
          <el-input-number v-model="formData.messageRetentionDays" :min="1" :max="365" />
        </el-form-item>

        <el-form-item label="自动清理消息">
          <el-switch v-model="formData.autoCleanMessage" />
        </el-form-item>

        <el-form-item label="权限管理">
          <el-checkbox-group v-model="formData.permissions">
            <el-checkbox label="user">用户管理</el-checkbox>
            <el-checkbox label="message">消息管理</el-checkbox>
            <el-checkbox label="settings">系统设置</el-checkbox>
          </el-checkbox-group>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleSave">保存设置</el-button>
          <el-button @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

interface SettingsForm {
  systemName: string
  apiUrl: string
  messageRetentionDays: number
  autoCleanMessage: boolean
  permissions: string[]
}

const formData = ref<SettingsForm>({
  systemName: 'WeChat Pad管理系统',
  apiUrl: 'http://localhost:8000',
  messageRetentionDays: 30,
  autoCleanMessage: true,
  permissions: ['user', 'message']
})

const handleSave = () => {
  console.log('保存设置', formData.value)
}

const handleReset = () => {
  // 重置表单数据到初始状态
  formData.value = {
    systemName: 'WeChat Pad管理系统',
    apiUrl: 'http://localhost:8000',
    messageRetentionDays: 30,
    autoCleanMessage: true,
    permissions: ['user', 'message']
  }
}
</script>

<style scoped lang="scss">
.settings-container {
  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .el-form {
    max-width: 600px;
  }
}
</style> 